package com.it.service;

import com.it.mapper.SysUserMapper;
import com.it.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SysUserServiceImpl implements SysUserService {

	//由spring创建对象并为变量赋值
	@Autowired
	private SysUserMapper clUserMapper;

	/**
	 * 1.查询所有图片信息
	 * @return
	 */
	public List<SysUser> findAll(){
		//1.调用roleMapper的findAll方法查询所有图片
		List<SysUser> list = clUserMapper.findAll();
		return list;
	}
	
	/**
	 * 2.根据id删除图片信息
	 * @param id
	 */
	public int deleteById(String id){
		//1.调用UserMapper的deleteById方法
		//根据id删除图片信息
		int result = clUserMapper.deleteById(id);
		return result;
	}
	
	/**
	 * 3.添加图片信息
	 * @param role
	 */
	public int addSysUser(SysUser role){
		int result = clUserMapper.addSysUser(role);
		return result;
	}
	
	/**
	 * 4.1.根据id查询图片信息
	 * @param id
	 * @return 
	 */
	public SysUser findById(String id){
		SysUser role = clUserMapper.findById(id);
		return role;
	}
	
	/**
	 * 4.2.根据id修改图片信息
	 * @param role
	 */
	public int updateById(SysUser role){
		int result = clUserMapper.updateById(role);
		return result;
	}

	/**
	 * 5、登录时查询有无该用户
	 * @param account
	 * @param password
	 * @param roleId
	 * @return
	 */
	public SysUser findByAccountAndPasswordAndRoleId(String account, String password, String roleId) {
		SysUser user = clUserMapper.findByAccountAndPasswordAndRoleId(account, password, roleId);
		return user;
	}

}
